#include "Bullet.h"
#include "Atlas.h"
void Bullet::on_collied()
{
	if (callback)
		callback();
}

bool Bullet::check_collied(const Vector2& position, const Vector2& size)
{
	return this->position.x + this->size.x / 2 >= position.x
		&& this->position.x + this->size.x / 2 <= position.x + size.x
		&& this->position.y + this->size.y / 2 >= position.y
		&& this->position.y + this->size.y / 2 <= position.y + size.y;
}

void Bullet::on_update(int delta)
{

}

void Bullet::on_draw(const Camera& camera) const
{
	if (is_debug) 
	{
		setfillcolor(RGB(255, 255, 255));
		setlinecolor(RGB(255, 255, 255));
		rectangle((int)position.x, (int)position.y, (int)(position.x + size.x), (int)(position.y + size.y));
		solidcircle((int)(position.x + size.x / 2), (int)(position.y + size.y / 2), 5);
	}
}

bool Bullet::check_if_exceeds_screen()
{
	return (position.x + size.x <= 0 || position.x >= getwidth()
		|| position.y + size.y <= 0 || position.y >= getheight());
}
